/**
 * 物品相关类型定义
 */

// 物品基本信息
export interface Item {
  id: number;
  object_id: number;
  object_name: string;
  category_id: number;
  grade: number;
  length: number;
  width: number;
  weight: number;
  pic: string;
  pre_pic: string;
  desc: string;
  create_time: string;
  update_time: string;
  delete_time: null | string;
  avg_price: number; // 平均价格
  price_change: {
    price: number;
  };
  price_24h_ago: number;
  category: {
    id: number;
    category_key: string;
    primary_class: string;
    second_class: string;
    second_class_cn: string;
    item_count: number;
    create_time: string;
    update_time: string;
    delete_time: null | string;
  };
  extraDetails: any | null;
  ammoList: any[];
  accessorySlots: any[];
  protectDetails: any | null; // 防护详情
  propDetails?: {
    id?: number;
    object_id?: number;
    type?: string; // 物品类型
    props_source?: string; // 物品来源
    effect?: string; // 效果
    duration?: number; // 持续时间
    cooldown?: number; // 冷却时间
    stack_limit?: number; // 堆叠限制
    durability?: number;
    protect_level?: number;
    aim_speed_percent?: number;
    aim_speed_battery?: number;
    aim_speed_color?: string;
    move_speed_percent?: number;
    move_speed_battery?: number;
    move_speed_color?: string;
    sound_effect_percent?: number;
    sound_effect_battery?: number;
    sound_effect_color?: string;
    face_mask_value?: string;
    face_mask_battery?: number;
    face_mask_color?: string;
    repair_efficiency?: string;
    protect_area?: string;
    durable_loss?: string;
    capacity?: any[];
    capacity_text?: string;
    create_time?: string;
    update_time?: string;
    delete_time?: null | string;
  } | null;
  ammoDetailsList?: Record<string, any>;
  ammoDetails?: {
    id?: number;
    object_id?: number;
    penetration_level?: number;
    harm_ratio?: number;
    armor_harm_level?: string;
    create_time?: string;
    update_time?: string;
    delete_time?: null | string;
  };
  accessoryDetails?: {
    recoil?: number;
    control_speed?: number;
    quick_separate?: boolean;
    hip_shot?: number;
    control_stable?: number;
    bomb_capacity?: number;
    effect_list?: any;
    advantage_effect_list?: any;
  };
  is_favorite?: boolean; // 是否已收藏
}

// 物品分类
export interface Category {
  primary_class: string;
  primary_class_cn?: string; // 主分类中文名称
  total_items: number;
  children: {
    id: number;
    category_key: string;
    second_class: string;
    second_class_cn: string;
    item_count: number;
    types?: {
      type_key: string;
      type_name?: string;
      item_count: number;
    }[];
  }[];
}

// 扩展的分类信息接口，支持解析后的分类结构
export interface ExtendedCategory extends Category {
  // 解析后的唯一分类列表
  uniqueChildren?: {
    id: number;
    categoryKey: string;
    secondClass: string;
    secondClassCn: string;
    itemCount: number;
    subType?: string;
    subTypeCn?: string;
    fullPath: string; // 完整的分类路径，如 "消耗品 > 维修套件"
  }[];
}

// 物品筛选条件
export interface ItemsFilter {
  page: number;
  pageSize: number;
  search: string;
  category: string;
  propType: string;
  minPrice: number | null;
  maxPrice: number | null;
  grade: string | number;
  sort: string;
}

// 物品列表响应
export interface ItemsResponse {
  items: Item[];
  total: number;
  pagination: {
    current: number;
    pageSize: number;
    total: number;
    pages: number;
  };
}

// 分类列表响应
export interface CategoriesResponse {
  categories: Category[];
  total: number;
}

// 价格历史数据响应
export interface PriceHistoryResponse {
  history: {
    time: string;
    price: number;
  }[];
  statistics: {
    min_price: number;
    max_price: number;
    avg_price: number;
    start_price: number;
    end_price: number;
    change_value: number;
    change_percent: number;
  };
} 